package com.keqiang.chart.impl.axis.impl.bar.horizontal

import android.graphics.Canvas
import android.graphics.Paint
import androidx.annotation.ColorInt
import com.keqiang.chart.impl.axis.impl.bar.BarEntity
import com.keqiang.chart.utils.ObjectPool

/**
 * 柱状图默认点击高亮
 *
 * @author Created by wanggaowan on 2022/9/2 16:04
 */
open class BarChartHorizontalHighLightRender @JvmOverloads constructor(
    chart: BarChartHorizontal,
    /**
     * 覆盖在柱状图上遮罩的颜色
     */
    @ColorInt val maskColor: Int = 0x55000000) : HighLightRender(chart) {

    override fun onDraw(canvas: Canvas, start: Float, top: Float, end: Float, bottom: Float, data: List<BarEntity>) {
        val paint = ObjectPool.obtainPaint<Paint>()
        paint.color = maskColor
        paint.style = Paint.Style.FILL
        data.forEach {
            canvas.drawRect(it.drawRectF, paint)
        }
        ObjectPool.recyclePaint(paint)
    }
}